<?php
namespace app\addons\controller;
// use app\index\
class Contact extends Base
{
    public function index()
    {
        $fid=request()->param('fid');

        $article=db("plugin_contact");
        $channel=db("channel");
        // $where['status']=1;
        $where['id']=1;
        // print_r($where);exit;
        // $where['type']=1;
        $mess=$article->where($where)->find();

        
        $fname=db("channel")->where("id",$fid)->value("name");
        $this->assign("fname",$fname);
        $this->assign("mess",$mess);
		return view('index');
    }
    public function addMessDone()  
    {
        $updid=request()->param('updid'); 
        $data=$_POST;
        $data['aid']=$this->userMsg['id'];
        if($updid){
           $res=db("plugin_contact")->where("id",$updid)->update($data); 
       }else{
            $res=db("plugin_contact")->insert($data);
       }        
        if($res){
            $mess['code']=200;
            $mess['msg']='保存成功';
        }else{
            $mess['code']=100;
            $mess['msg']='保存失败';
        }        
        return json_encode($mess);
    }   
}
